@extends('layout.app')

@section('content')

    <div class="form-inline">

        <div class="form-group has-success">
            <input class="form-control" id="begin_time" placeholder="开始时间"/>
        </div>
        <div class="form-group has-success">
            <input class="form-control" id="end_time" placeholder="结束时间"/>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-default"><i class="fa fa-search"></i> 查询</button>
        </div>
    </div>
    <div class="separator"></div>
    <div class="box-body">

        <table id="rowed3"></table>
        <div id="prowed3"></div>

    </div>

<script>

$(document).ready(function() {

	var data = {
        datatype: "json",
        rowNum: 20,
        rowList: [20, 40, 80],
        height: "auto",
        pager: '#prowed3',
        viewrecords: true,
        url :"/user/reg",
        postData: postData(),
        colNames: ['注册时间', '注册数' , ''],
        colModel: [
            {
                name: "date",
                align: 'center',
            }, {
                name: 'COUNT(1)',
                align: 'center',
            }, {
                name: 'count',
                hidden: true

            }],
        footerrow: true,
        caption: '<i class="fa fa-list"></i> {{$label2}}',
        sortname: "date",
        sortorder: "desc",
        loadError: function(xhr, status, error) {
            $.gritter.add({
                title: "Server Status: " + xhr.status,
                text: error,
                sticky: false,
                time: '',
            });
        },
        gridComplete: function() {

            var count = 0;
            if (($(this).getCol("count").length)){

                count = $(this).getCol("count")[0];
            }

            $(this).footerData("set", {

                "date": "总数: " + count,
                "COUNT(1)":"合计: " + $(this).getCol("COUNT(1)",false,"sum")});
        }
    };

    jQuery("#rowed3").jqGrid(data);

    $(".form-inline .form-control").datepicker({
        dateFormat: 'yy-mm-dd',
        monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
        dayNamesMin: ['日','一','二','三','四','五','六'] });

    $("#button").click(function () {

        jQuery("#rowed3").setGridParam({postData: postData()}).trigger("reloadGrid");
    });
});

function postData() {

    return {
        begin_time: $("#begin_time").val(),
        end_time: $("#end_time").val(),
    }
}

</script>
@endsection